package com.freewater.springboot.demo.ioc.injectionpoint;

import org.springframework.beans.factory.InjectionPoint;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;

@Component
public class FactoryMethodComponent {

    @Bean
    @Scope("prototype")
    public BeanB prototypeInstance(InjectionPoint injectionPoint) {
        return new BeanB("prototypeInstance for " + injectionPoint.getMember());
    }

    @Bean
    @Scope("prototype")
    public BeanA beanA(BeanB beanB) {
        final BeanA beanA = new BeanA();
        beanA.setBeanB(beanB);
        return beanA;
    }
}
